package com.ase.singleton.listnode;

/**
 * @author gyhstart
 * @create 2021/3/6 - 20:26
 **/
public class ListNode {

       public static void traverse(Node head){
        while (head != null){
            System.out.println(head.data);
            head = head.next;
        }
    }

    private static class Node{
        int data;
        Node next;

        public Node(int data){
            this.data = data;
        }
    }

    public static void main(String[] args) {

        Node node1 = new Node(1);
        Node node2 = new Node(2);
        Node node3 = new Node(3);
        Node node4 = new Node(4);
        node1.next = node2;
        node2.next = node3;
        node3.next = node4;

        traverse(node1);
    }
}

